package com.guet.comment.controller;

import com.guet.comment.beans.vo.CommentDateVO;
import com.guet.comment.service.ICommentService;
import com.guet.common.entity.PageDataVO;
import com.guet.common.entity.PageVO;
import com.guet.common.response.ResultCodeEnum;
import com.guet.common.response.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Li
 * @create 2022-12-16-21:47
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    ICommentService commentService;



    @RequestMapping("/page")
    public ResultVO<PageDataVO<CommentDateVO>> select(@RequestParam Integer issueId, PageVO pageVO){

        PageDataVO<CommentDateVO> pageDataVO = commentService.page(issueId, pageVO);

        return new ResultVO<>(ResultCodeEnum.SUCCESS, pageDataVO);

    }

    @RequestMapping("/add")
    public ResultVO<PageDataVO<CommentDateVO>> add(@RequestParam Integer userId, @RequestParam Integer issueId, @RequestParam String content){
        PageDataVO<CommentDateVO> pageDataVO = commentService.add(issueId, userId, content);

        return new ResultVO<>(ResultCodeEnum.SUCCESS, pageDataVO);
    }

    @RequestMapping("/delete")
    public ResultVO<PageDataVO<CommentDateVO>> delete(@RequestParam Integer issueId, @RequestParam Integer userId, @RequestParam Integer id){

        PageDataVO<CommentDateVO> pageDataVO = commentService.delete(issueId, userId, id);

        return new ResultVO<>(ResultCodeEnum.SUCCESS, pageDataVO);

    }






}
